﻿using System;
using System.Linq;
using System.Xml.Linq;
using Common.Constants;
using Common.Helper;
using Common.Interface;
using MainProcessor.Processors;
using NUnit.Framework;

namespace Test.Main.Processors
{
    [TestFixture]
    public class LatestParentMeasuresProcessorTests
    {
        private ILatestParentMeasures latestParentMeasures;

        [SetUp]
        public void SetUp()
        {
            latestParentMeasures = new LatestParentMeasuresProcessor();
        }

        [Test]
        public void ShouldReturntheLatestAumMeasureTermObject()
        {
            var xml = XElement.Parse(ConstantXml.TestString);

            var element = (from parentContainer in xml.Descendants(XmlConstants.ParentContainer)
                           select parentContainer).FirstOrDefault();


            latestParentMeasures.Initialise(element, XmlConstants.ParentMeasure, XmlConstants.LegacyType, ParentMeasureType.AuM.ToDescription());
            Assert.AreEqual(101m, latestParentMeasures.TotalCapacity);
            Assert.AreEqual(100, latestParentMeasures.TotalEmployees);
            Assert.AreEqual(null, latestParentMeasures.MacSize);
            Assert.IsNull(latestParentMeasures.FundSizeOnshore);
            Assert.AreEqual(new DateTime(2013,1,01), latestParentMeasures.AsOfDate);
            Assert.AreEqual(null, latestParentMeasures.AssetsInStrategy);
            Assert.AreEqual(null, latestParentMeasures.AuM);
            Assert.AreEqual(null, latestParentMeasures.FundSizeOffshore);
            Assert.AreEqual(null, latestParentMeasures.FundSizeOnshore);


        }
    }
}

